import React from 'react';
import ReactDOM from "react-dom";

class LifeChild extends React.Component {
  constructor(props) {
    super();
    this.state = {
      count: 0,
    };
    console.log("LifeChild constructor ...");
  }

  static getDerivedStateFromProps(props, state) {
    console.log("LifeChild getDerivedStateFromProps ...", props, state);
    return state;
  }

  render() {
    console.log("LifeChild render ...");
    return (
      <button onClick = { this.props.onClick }>+ 1</button>
    );
  }

  componentDidMount() {
    // undefined();
    console.log("LifeChild componentDidMount ...");
  }

  shouldComponentUpdate(nextProps, nextState) {
    console.log("LifeChild shouldComponentUpdate ...", nextProps, nextState);
    return true;
  }

  getSnapshotBeforeUpdate(prevProps, prevState) {
    console.log("LifeChild getSnapshotBeforeUpdate ...", prevProps, prevState);
    return null;
  }

  componentDidUpdate(prevProps, prevState) {
    console.log("LifeChild componentDidUpdate ...", prevProps, prevState);
  }

  componentWillUnmount() {
    console.log("LifeChild componentWillUnmount ...");
  }
}

export default LifeChild;
